// video support class, added by regret
#ifndef VID_SUPPORT_H
#define VID_SUPPORT_H

class VidSupport {
public:
	VidSupport();
	~VidSupport();

	bool init(unsigned char* _image, unsigned _width, unsigned _height, int _rotate, unsigned _pitch);
	void setAspect(double _aspect) { aspect = _aspect; }

	void copyImage(unsigned char* pd, unsigned pitch);
	bool scaleImage(void* rect, unsigned gameWidth, unsigned gameHeight);

	unsigned getWidth() { return width; }
	unsigned getHeight() { return height; }
	int getRotate() { return rotate; }

	void copyImageRotate(unsigned char* ps, unsigned srcPitch, unsigned char* pd, unsigned dstPitch,
		unsigned inwidth, unsigned inheight, int inrotate);

	void postCopyImage(unsigned char* pd, unsigned dstPitch);

	void copyImageIn(unsigned char* dst, unsigned dstPitch, unsigned char* src, unsigned srcPitch, unsigned width, unsigned height);

	unsigned rounded_power_of_two(unsigned n) {
		n--;
		n |= n >>  1;
		n |= n >>  2;
		n |= n >>  4;
		n |= n >>  8;
		n |= n >> 16;
		return n + 1;
	}

private:
	unsigned char* image;
	unsigned width, height;
	unsigned pitch;
	int rotate;
	double aspect;
};

extern VidSupport vidSupport;

#endif
